print("查询课程表")

import datetime
time = datetime.datetime.today().weekday()
week_time = int(time)

print("请验证你的用户身份")

# 模拟数据库数据
user_data = ["lizhubo","lihui","guosiwen"]
password_data = ["123","1234","12345"]
vip_user_data = ["lihaha"]
vip_password_data = ["1234567"]
# 输入次数(只有三次登录的机会)

count = 3
while True:
    count -=1

# 登陆中
    username = input("账号：")
    password = input("密码：")

    # 先判断账号是否是本网站用户
    if username in user_data or username in vip_user_data:

        # 再判断密码是否正确
        if password in password_data or password in vip_password_data:
            print("欢迎", username, "使用本网站")

            # 再判断是否为VIP用户
            if username in vip_user_data:
                # 再判断密码是否正确

                if password in vip_password_data:
                    count = 10  # 代表有10次查询课表的机会
                    print("Dear VIP!")
                    print("Welcome ", username, "to use this website")
                    print("You have ", count, " chances")

                # 用户功能提供
                count = 10  # 代表有10次查询课表的机会
                print("你想要什么功能？(1)查询具体星期几的课表；(2)查询当前课表","请问你的选择是：")
                choice = int(input("请输入你的选择: "))  # 将input的字符串转为整数
                if choice == 1:

                    import time
                    today = time.strftime("%A")
                    now = int(time.strftime("%H%M"))
                    print("现在时间{}".format(time.strftime("%H:%M")))

                    # 尝试添加查询功能

                    class1 = (
                    "没有任何课程噢，继续加油！", "08:00-09:30 毛概；09：45-12：00 创业基础；14:30-15:55 h5制作；16:10 死亡英语；18:45-20:10 养生乒乓球",
                    "又没有课了啊！继续搬砖", "早八的英语＋三节python，还有下午的毛概知识", "黄＋🐟，AI")  # 单引号’‘是一个元素，双引号“”是多个元素用的
                    time1 = ("星期一", "星期二", "星期三", "星期四", "星期五")
                    inquire = input("如果你想查询课表，请输入你要查询的时间(如星期一 OR 星期二）：")  # （inquire）这个东西是自变量
                    if inquire in time1:
                        place = time1.index(inquire)  # time.index() 查询列表中某个元素所在的位置
                        print(class1[place])
                    count -= 1
                    print("Do you want to continue querying your course? ","You have", count, "chances")
                    # 增加用户选择和用户输入，为达到重复查询课表的目的
                    choose_true = "Y"
                    choose_false = "N"
                    while True:

                        user_choose = input("Please enter Y or N：")
                        if user_choose == choose_true:
                            inquire = input("如果你想查询课表，请输入你要查询的时间(如星期一 OR 星期二）：")  # （inquire）这个东西是自变量
                            if inquire in time1:
                                place = time1.index(inquire)  # time.index() 查询列表中某个元素所在的位置
                                print(class1[place])
                            count -= 1
                            print("Do you want to continue querying your course? "
                                  "You have", count, "chances")
                        if count == 3:
                            print("你今天还有三次查询机会哟！注意使用！")
                        if count == 0:
                            print("你所有查询机会已经用完啦！请明天再来！")
                            break



            if username in user_data:
                # 判断为普通用户的话

                if password in password_data:
                    count = 5  # 代表有5次查询课表的机会
                    print("Welcome ", username, "to use this website")
                    print("You have ", count, " chances")

                # 用户功能提供
                count = 5  # 代表有5次查询课表的机会
                print("请问你是想要查询课表吗？是的(1)；不是(2)","请问你的选择是：")
                choice = int(input("请输入你的选择: "))  # 将input的字符串转为整数
                if choice == 1:
                    import time

                    today = time.strftime("%A")
                    now = int(time.strftime("%H%M"))
                    print("现在时间{}".format(time.strftime("%H:%M")))

                    # 尝试添加查询功能

                    class1 = (
                    "没有任何课程噢，继续加油！", "08:00-09:30 毛概；09：45-12：00 创业基础；14:30-15:55 h5制作；16:10 死亡英语；18:45-20:10 养生乒乓球",
                    "又没有课了啊！继续搬砖", "早八的英语＋三节python，还有下午的毛概知识", "黄＋🐟，AI")  # 单引号’‘是一个元素，双引号“”是多个元素用的
                    time1 = ("星期一", "星期二", "星期三", "星期四", "星期五")
                    inquire = input("如果你想查询课表，请输入你要查询的时间(如星期一 OR 星期二）：")  # （inquire）这个东西是自变量
                    if inquire in time1:
                        place = time1.index(inquire)  # time.index() 查询列表中某个元素所在的位置
                        print(class1[place])
                    count -= 1
                    print("Do you want to continue querying your course? ","You have", count, "chances")
                    # 增加用户选择和用户输入，为达到重复查询课表的目的
                    choose_true = "Y"
                    choose_false = "N"
                    while True:

                        user_choose = input("Please enter Y or N：")
                        if user_choose == choose_true:
                            inquire = input("如果你想查询课表，请输入你要查询的时间(如星期一 OR 星期二）：")  # （inquire）这个东西是自变量
                            if inquire in time1:
                                place = time1.index(inquire)  # time.index() 查询列表中某个元素所在的位置
                                print(class1[place])
                            count -= 1
                            print("Do you want to continue querying your course? "
                                  "You have", count, "chances")
                        if count == 3:
                            print("你今天还有三次查询机会哟！注意使用！")
                        if count == 0:
                            print("你所有查询机会已经用完啦！请明天再来！")
                            break
            else:
                print("当前课表情况")
                import time

                # 根据时间查询课表，显示所在上的课程
                today = time.strftime("%A")
                now = int(time.strftime("%H%M"))
                print("现在时间{}".format(time.strftime("%H:%M")))
                if today == "Monday":
                    print("no course")
                elif today == "Tuesday":
                    if 800 < now < 935:
                        print("毛概")
                    elif 945 < now < 1200:
                        print("创业实践")
                    elif 1430 < now < 1555:
                        print("h5网页制作")
                    elif 1610 < now < 1735:
                        print("大学英语")
                    elif 1845 < now < 2010:
                        print("养生乒乓球")
                    else:
                        print("你还没有课。")
                elif today == "Wednesday":
                    print("今天休息日，你还没有课。")
                elif today == "Thursday":
                    if 800 < now < 930:
                        print("大学英语")
                    elif 945 < now < 1200:
                        print("python秃头课")
                    elif 1430 < now < 1655:
                        print("毛概理论")
                    else:
                        print("你还没有课。")
                elif today == "Friday":
                    if 800 < now < 930:
                        print("黄＋🐟")
                    elif 1035 < now < 1200:
                        print("AI设计课")
                    else:
                        print("你还没有课。")
                else:
                    print("放假！")
            break

    else:

        if 0 < count < 3:
            print("账号或者密码出错了，请重新输入")
        if count == 0:
            print("你都输入三次了！不许输了！五分钟后再来吧！")


            from datetime import datetime, timedelta
            from threading import Timer


            def get_sleep_time():
                now = datetime.now()
                next_run = now.replace(minute=int(now.minute / 5) * 5, second=0, microsecond=0) + timedelta(minutes=5)
                return (next_run - now).total_seconds()


            def dowork():
                now = datetime.now()
                print('Doing some work at', now)
                schedule_next_run()


            def schedule_next_run():
                sleep_time = get_sleep_time()
                print(f'sleeping for {sleep_time} seconds')
                t = Timer(sleep_time, dowork)
                t.daemon = True
                t.start()


            print('Starting work schedule')
            schedule_next_run()
            input('Doing work every 5 minutes. Press enter to exit')

            break
        else:
            print("您输入的账号或密码不正确，请重新输入。您还有", count, "次机会")
